package yesjava.news.web;

import yesjava.news.entity.News;
import yesjava.news.service.NewsService;
import yesjava.news.service.NewsServiceImpl;
import yesjava.news.utils.JSONUtil;

import javax.servlet.ServletException;
import javax.servlet.annotation.WebServlet;
import javax.servlet.http.HttpServlet;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import java.io.IOException;
import java.util.HashMap;
import java.util.Map;

@WebServlet("/toupdate.do")
public class ToUpdateNewsServlet extends HttpServlet {
    private NewsService newsService = new NewsServiceImpl();
    @Override
    protected void service(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
        Integer id = Integer.parseInt(request.getParameter("id"));
        System.out.println("ToUpdateNewsServlet - > 新闻的id:"+id);

        News news = newsService.getNewsById(id);
        JSONUtil.printJSON(news,response);
    }
}
